#include "LineType.h"

LineType
line_fetch_type (ObjectStringApplication* line)
{
        char ch;
        if (!line)
                return LINE_TYPE_END;
        object_string_purify_space (OBJECT_STRING (line));
        object_string_application_rewind (line);
        ch = object_string_application_iter (line);
        if (ch == '[') {
                if (OBJECT_STRING (line)->charset[OBJECT_STRING (line)->length -
                                                  1] == ']') {
                        return LINE_TYPE_TOP_MARK;
                } else {
                        return LINE_TYPE_OTHER;
                }
        }
        if (ch == '#')
                return LINE_TYPE_ANNOTATION;
        while (ch != '\0') {
                if (ch == '=')
                        return LINE_TYPE_KEYVALUE;
                ch = object_string_application_iter (line);
        }
        return LINE_TYPE_OTHER;
}
